//
//  YKCover.m
//  youkan
//
//  Created by mac mini on 16/2/24.
//  Copyright © 2016年 Honsintech. All rights reserved.
//

#import "YKCover.h"

@implementation YKCover
-(void)setDimBackground:(BOOL)dimBackground{
    _dimBackground =dimBackground;

    if (dimBackground) {
        self.backgroundColor =[UIColor blackColor];
        self.alpha = 0.5;
    }else{
        self.alpha = 1;
        self.backgroundColor =[UIColor clearColor];
    }
}

+(instancetype)show{
    YKCover *cover =[[YKCover alloc]initWithFrame:[UIScreen mainScreen].bounds];
    cover.backgroundColor =[UIColor clearColor];
    [YKKeyWindow addSubview:cover];

    return cover;
}
// 点击蒙板的时候做事情
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    // 移除蒙板
    [self removeFromSuperview];

    // 通知代理移除菜单
    if ([_delegate respondsToSelector:@selector(coverDidClickCover:)]) {
        [_delegate coverDidClickCover:self];
    }

}
@end
